package org.com.fw.web.security;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.security.core.AuthenticationException;
import org.springframework.security.web.AuthenticationEntryPoint;

public class MarsLoginEntry implements AuthenticationEntryPoint {

	/**
	 * login入口。
	 */
	private String defaultLoginUrl = "/login.jsp";

	@Override
	public void commence(HttpServletRequest arg0, HttpServletResponse arg1, AuthenticationException arg2)
			throws IOException, ServletException {
		String ctxPath = arg0.getContextPath();
		arg1.sendRedirect(ctxPath + this.defaultLoginUrl);
	}

	/**
	 * 默认入口设定。
	 * 
	 * @param defaultLoginUrl
	 */
	public void setDefaultLoginUrl(String defaultLoginUrl) {
		this.defaultLoginUrl = defaultLoginUrl;
	}

}